import { http } from '@/utils/request'
import type { Facility, UserLocation, NavigationRoute, ApiResponse } from '@/types'

// 获取场地地图
export const getVenueMap = (params?: {
  floor?: string;
}): Promise<ApiResponse<{
  mapUrl: string;
  facilities: Facility[];
}>> => {
  return http.get('/client/navigation/map', { params })
}

// 获取用户位置
export const getUserLocation = (): Promise<ApiResponse<UserLocation>> => {
  return http.get('/client/navigation/location')
}

// 更新用户位置
export const updateUserLocation = (data: {
  latitude: number;
  longitude: number;
  floor?: string;
  accuracy?: number;
}): Promise<ApiResponse<UserLocation>> => {
  return http.post('/client/navigation/location', data)
}

// 获取导航路线
export const getNavigationRoute = (params: {
  from: string; // facility_id
  to: string; // facility_id
}): Promise<ApiResponse<NavigationRoute>> => {
  return http.get('/client/navigation/route', { params })
}

// 搜索设施
export const searchFacilities = (params?: {
  q?: string;
  floor?: string;
  type?: string;
}): Promise<ApiResponse<Facility[]>> => {
  return http.get('/client/navigation/search', { params })
}

// 获取设施类型统计
export const getFacilityTypes = (params?: {
  floor?: string;
}): Promise<ApiResponse<Array<{
  type: string;
  count: number;
}>>> => {
  return http.get('/client/navigation/facility-types', { params })
} 